package com.home.duy.GUI;

import javax.swing.JPanel;
import javax.swing.JInternalFrame;

import com.home.Common.Resources_Duy;
import java.awt.Rectangle;
import javax.swing.JButton;
import com.home.Common.Common;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JSpinner;
import javax.swing.JTable;
import javax.swing.SpinnerDateModel;

import com.home.duy.code.Model.QLCaLamTableModel;
import com.home.duy.code.Model.QLNVTableModel;
import com.home.duy.code.components.ImageBackground;
import com.home.duy.code.components.ImagePanel;

import javax.swing.JTextField;
import javax.swing.BorderFactory;
import java.awt.GridBagLayout;
import java.util.Calendar;
import javax.swing.JTextArea;

public class QuanLyCaLam extends JInternalFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private QLCaLamTableModel model = null;
	
	
	private JPanel jContentPane = null;
	private JPanel panelDuLieu = null;
	private JScrollPane scrollPaneTable = null;
	private JTable tableData = null;
	private JPanel panelCommand = null;
	private JButton btnThem = null;
	private JButton btnSua = null;
	private JButton btnXoa = null;
	private JTextField txtFilter = null;
	private JLabel jLabel7 = null;
	private JSpinner spinnerHourBD = null;
	private JSpinner spinnerMiBD = null;
	private JSpinner spinnerAPBD = null;
	private JSpinner spinnerHourKT = null;
	private JSpinner spinnerMiKT = null;
	private JSpinner spinnerAPKT = null;

	private JPanel panelChiTiet = null;

	private JLabel jLabel = null;

	private JTextField txtTenCa = null;

	private JLabel jLabel1 = null;

	private JLabel jLabel2 = null;

	private JLabel jLabel3 = null;

	private JScrollPane scrollPaneGhiChu = null;

	private JTextArea txtGhiChu = null;

	private ImagePanel panelComponents = null;

	/**
	 * This is the xxx default constructor
	 */
	public QuanLyCaLam() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(800, 600);
		this.setContentPane(getJContentPane());
		this.setTitle(Resources_Duy.TITLE_MENU_ITEM_QLCALAM);
		this.setClosable(true);
		this.setIconifiable(true);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getPanelDuLieu(), null);
			jContentPane.add(getPanelChiTiet(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes panelDuLieu	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getPanelDuLieu() {
		if (panelDuLieu == null) {
			panelDuLieu = new JPanel();
			panelDuLieu.setLayout(null);
			panelDuLieu.setBounds(new Rectangle(15, 16, 764, 255));
			panelDuLieu.setBorder(BorderFactory.createTitledBorder("Danh Sách Ca Làm"));
			panelDuLieu.add(getScrollPaneTable(), null);
			panelDuLieu.add(getPanelCommand(), null);
		}
		return panelDuLieu;
	}

	/**
	 * This method initializes scrollPaneTable	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getScrollPaneTable() {
		if (scrollPaneTable == null) {
			scrollPaneTable = new JScrollPane();
			scrollPaneTable.setBounds(new Rectangle(15, 51, 738, 188));
			scrollPaneTable.setViewportView(getTableData());
		}
		return scrollPaneTable;
	}

	/**
	 * This method initializes tableData	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private JTable getTableData() {
		if (tableData == null) {
			tableData = new JTable();
			model = new QLCaLamTableModel();
			
			tableData.setModel(model);
		}
		return tableData;
	}

	/**
	 * This method initializes panelCommand	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getPanelCommand() {
		if (panelCommand == null) {
			jLabel7 = new JLabel();
			jLabel7.setBounds(new Rectangle(494, 1, 25, 23));
			jLabel7.setText("");
			jLabel7.setIcon(Common.getImageIcon(Resources_Duy.ICON_PATH + "filter.png"));
			panelCommand = new JPanel();
			panelCommand.setLayout(null);
			panelCommand.setBounds(new Rectangle(16, 26, 737, 27));
			panelCommand.add(getBtnThem(), null);
			panelCommand.add(getBtnSua(), null);
			panelCommand.add(getBtnXoa(), null);
			panelCommand.add(getTxtFilter(), null);
			panelCommand.add(jLabel7, null);
		}
		return panelCommand;
	}

	/**
	 * This method initializes btnThem	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnThem() {
		if (btnThem == null) {
			btnThem = new JButton();
			btnThem.setBounds(new Rectangle(0, 0, 90, 26));
			btnThem.setIcon(Common.getImageIcon(Resources_Duy.ICON_PATH + "add_new.png"));
			btnThem.setText("Thêm");
			btnThem.setContentAreaFilled(false);
		}
		return btnThem;
	}

	/**
	 * This method initializes btnSua	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnSua() {
		if (btnSua == null) {
			btnSua = new JButton();
			btnSua.setBounds(new Rectangle(90, 0, 85, 26));
			btnSua.setIcon(Common.getImageIcon(Resources_Duy.ICON_PATH + "edit.png"));
			btnSua.setText("Sửa");
			btnSua.setContentAreaFilled(false);
		}
		return btnSua;
	}

	/**
	 * This method initializes btnXoa	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBtnXoa() {
		if (btnXoa == null) {
			btnXoa = new JButton();
			btnXoa.setBounds(new Rectangle(175, 0, 85, 26));
			btnXoa.setIcon(Common.getImageIcon(Resources_Duy.ICON_PATH + "delete.png"));
			btnXoa.setText("Xóa");
			btnXoa.setContentAreaFilled(false);
		}
		return btnXoa;
	}

	/**
	 * This method initializes txtFilter	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtFilter() {
		if (txtFilter == null) {
			txtFilter = new JTextField();
			txtFilter.setBounds(new Rectangle(519, 0, 217, 26));
		}
		return txtFilter;
	}

	/**
	 * This method initializes panelChiTiet	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getPanelChiTiet() {
		if (panelChiTiet == null) {
			jLabel3 = new JLabel();
			jLabel3.setText(" Ghi Chú");
			jLabel3.setBounds(new Rectangle(3, 150, 86, 25));
			jLabel2 = new JLabel();
			jLabel2.setText(" TG Kết Thúc");
			jLabel2.setBounds(new Rectangle(1, 102, 86, 24));
			jLabel1 = new JLabel();
			jLabel1.setText(" TG Bắt Đầu ");
			jLabel1.setBounds(new Rectangle(1, 48, 85, 27));
			jLabel = new JLabel();
			jLabel.setText(" Tên Ca Làm ");
			jLabel.setBounds(new Rectangle(0, 1, 82, 24));
			panelChiTiet = new JPanel();
			panelChiTiet.setLayout(null);
			panelChiTiet.setBorder(BorderFactory.createTitledBorder("Chi Tiết Ca Làm"));
			panelChiTiet.setBounds(new Rectangle(14, 297, 764, 260));
			panelChiTiet.add(getPanelComponents(), null);
		}
		return panelChiTiet;
	}
	
	/**
	 * This method initializes spinnerHourBD	
	 * 	
	 * @return javax.swing.JSpinner	
	 */
	private JSpinner getspinnerHourBD()
	{
		if(spinnerHourBD == null)
		{
			spinnerHourBD = new JSpinner();
			SpinnerDateModel sm = new SpinnerDateModel(Common.getDateDefault(), null, null, Calendar.HOUR);
			spinnerHourBD.setModel(sm);
			spinnerHourBD.setEditor(new JSpinner.DateEditor(spinnerHourBD,"hh"));
			spinnerHourBD.setBounds(new Rectangle(106, 48, 54, 25));
			
		}
		return spinnerHourBD;
	}
	
	/**
	 * This method initializes spinnerMiBD	
	 * 	
	 * @return javax.swing.JSpinner	
	 */
	private JSpinner getSpinnerMiBD()
	{
		if(spinnerMiBD == null)
		{
			spinnerMiBD = new JSpinner();
			SpinnerDateModel sm = new SpinnerDateModel(Common.getDateDefault(), null, null, Calendar.MINUTE);
			spinnerMiBD.setModel(sm);
			spinnerMiBD.setEditor(new JSpinner.DateEditor(spinnerMiBD,"mm"));
			spinnerMiBD.setBounds(new Rectangle(164, 48, 54, 25));
			
		}
		return spinnerMiBD;
	}
	
	/**
	 * This method initializes spinnerMiBD	
	 * 	
	 * @return javax.swing.JSpinner	
	 */
	private JSpinner getSpinnerAPBD()
	{
		if(spinnerAPBD == null)
		{
			spinnerAPBD = new JSpinner();
			SpinnerDateModel sm = new SpinnerDateModel(Common.getDateDefault(), null, null, Calendar.AM_PM);
			spinnerAPBD.setModel(sm);
			spinnerAPBD.setEditor(new JSpinner.DateEditor(spinnerAPBD,"a"));
			spinnerAPBD.setBounds(new Rectangle(219, 47, 54, 25));
		}
		return spinnerAPBD;
	}
	
	/**
	 * This method initializes spinnerHourBD	
	 * 	
	 * @return javax.swing.JSpinner	
	 */
	private JSpinner getspinnerHourKT()
	{
		if(spinnerHourKT == null)
		{
			spinnerHourKT = new JSpinner();
			SpinnerDateModel sm = new SpinnerDateModel(Common.getDateDefault(), null, null, Calendar.HOUR);
			spinnerHourKT.setModel(sm);
			spinnerHourKT.setEditor(new JSpinner.DateEditor(spinnerHourKT,"hh"));
			spinnerHourKT.setBounds(new Rectangle(107, 99, 54, 25));
			
		}
		return spinnerHourKT;
	}
	
	/**
	 * This method initializes spinnerMiBD	
	 * 	
	 * @return javax.swing.JSpinner	
	 */
	private JSpinner getSpinnerMiKT()
	{
		if(spinnerMiKT == null)
		{
			spinnerMiKT = new JSpinner();
			SpinnerDateModel sm = new SpinnerDateModel(Common.getDateDefault(), null, null, Calendar.MINUTE);
			spinnerMiKT.setModel(sm);
			spinnerMiKT.setEditor(new JSpinner.DateEditor(spinnerMiKT,"mm"));
			spinnerMiKT.setBounds(new Rectangle(167, 100, 54, 25));
			
		}
		return spinnerMiKT;
	}
	
	/**
	 * This method initializes spinnerMiBD	
	 * 	
	 * @return javax.swing.JSpinner	
	 */
	private JSpinner getSpinnerAPKT()
	{
		if(spinnerAPKT == null)
		{
			spinnerAPKT = new JSpinner();
			SpinnerDateModel sm = new SpinnerDateModel(Common.getDateDefault(), null, null, Calendar.AM_PM);
			spinnerAPKT.setModel(sm);
			spinnerAPKT.setEditor(new JSpinner.DateEditor(spinnerAPKT,"a"));
			spinnerAPKT.setBounds(new Rectangle(222, 101, 54, 25));
		}
		return spinnerAPKT;
	}
	
	/**
	 * This method initializes txtTenCa	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getTxtTenCa() {
		if (txtTenCa == null) {
			txtTenCa = new JTextField();
			txtTenCa.setBounds(new Rectangle(105, 2, 191, 26));
		}
		return txtTenCa;
	}

	/**
	 * This method initializes scrollPaneGhiChu	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getScrollPaneGhiChu() {
		if (scrollPaneGhiChu == null) {
			scrollPaneGhiChu = new JScrollPane();
			scrollPaneGhiChu.setBounds(new Rectangle(108, 148, 366, 52));
			scrollPaneGhiChu.setViewportView(getTxtGhiChu());
		}
		return scrollPaneGhiChu;
	}

	/**
	 * This method initializes txtGhiChu	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getTxtGhiChu() {
		if (txtGhiChu == null) {
			txtGhiChu = new JTextArea();
		}
		return txtGhiChu;
	}

	/**
	 * This method initializes panelComponents	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private ImagePanel getPanelComponents() {
		if (panelComponents == null) {
			panelComponents = new ImagePanel(Resources_Duy.IMAGE_PATH+"bgQLCL.png");
			panelComponents.setLayout(null);
			panelComponents.setBounds(new Rectangle(13, 27, 745, 200));
			panelComponents.add(jLabel, null);
			panelComponents.add(getTxtTenCa(), null);
			panelComponents.add(jLabel1, null);
			panelComponents.add(getspinnerHourBD(), null);
			panelComponents.add(getSpinnerMiBD(), null);
			panelComponents.add(getSpinnerAPBD(), null);
			panelComponents.add(jLabel2, null);
			panelComponents.add(getspinnerHourKT(), null);
			panelComponents.add(getSpinnerMiKT(), null);
			panelComponents.add(getSpinnerAPKT(), null);
			panelComponents.add(jLabel3, null);
			panelComponents.add(getScrollPaneGhiChu(), null);
		}
		return panelComponents;
	}
	
}
